<%-- 
    Document   : viewSingleUser
    Created on : Nov 22, 2012, 10:46:25 PM
    Author     : Hiro
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="tracker.Torrents"%>
<%@page import="java.util.Collection"%>
<%@page import="tracker.Users"%>
<%@page import="tracker.TrackerHelper"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="Trackertag" uri="/WEB-INF/tlds/TrackerTag_library" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <LINK REL=StyleSheet HREF="../style/style.css" TYPE="text/css" MEDIA=screen>
        <title>View User</title>
    </head>
    <%
        Boolean isLogin = false;
        int userId = -1;
        try {
            Cookie[] ck = request.getCookies();
            if (ck != null) {
                for (int i = 0; i < ck.length; i++) {
                    if ("userId".equals(ck[i].getName())) { //Finding Username Cookie
                        userId = Integer.parseInt(ck[i].getValue());
                        i = ck.length;
                        isLogin = true;
                    }
                }

            }
            if (isLogin == false) {
                response.sendRedirect("login.jsp");
                return;
            }
        } catch (Exception e) {
        }

        try {
            /* TODO output your page here. You may use following sample code. */
            if (request.getParameter("userId") != null) {
                try {
                    String userIdTemp = request.getParameter("userId");
                    userId = Integer.parseInt(userIdTemp);
                } catch (Exception e) {
                    out.println("<div style=\"width:800px; margin:0 auto; padding-top: 250px\"><h3>" + e.getMessage() + "</h3></div>");
                }
            }
        } catch (Exception e) {
            out.println("<div style=\"width:800px; margin:0 auto; padding-top: 250px\"><h3>" + e.getMessage() + "</h3></div>");
        } finally {
            //out.close();
        }

    %>

    <body>
        <jsp:include page="navigation.jsp" />
        <div id="torrent-list-form" style="margin-top: 100px;">
            <div style="padding-left: 10px;"><h2>User</h2></div>
            <ul id="holder"> 
                <Trackertag:viewSingleUserHandler userId="<%=userId%>"/>
                <input class="bg-color-purple" style="color: whitesmoke" type="button" name="changePass" value="Change Your Password" onclick="parent.location='changePassword.jsp'">
            </ul> 
        </div>
    </body>

</html>
